package com.chixing.service.impl;

import com.chixing.mapper.CustomerMapper;
import com.chixing.pojo.Customer;
import com.chixing.service.BudingSetService;
import com.chixing.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BudingSetServiceImpl implements BudingSetService {
    @Autowired
    private CustomerMapper customerMapper;
    @Override
    public ServerResponse getById(Integer id) {
        Customer customer=customerMapper.selectByPrimaryKey(id);
        if (customer!=null)
            return ServerResponse.getSuccess(customer);
        return ServerResponse.getFail(null);
    }

    @Override
    public ServerResponse update(Integer custId,String custEmail,String custName,String custIdcard) {
        Customer customer = customerMapper.selectByPrimaryKey(custId);
        customer.setCustEmail(custEmail);
        customer.setCustName(custName);
        customer.setCustIdcard(custIdcard);
        System.out.println(111111111);
        int rows = customerMapper.updateByPrimaryKey(customer);
        if (rows>0)
            return ServerResponse.updateSuccess(rows);
        return ServerResponse.updateFail(null);
    }

    @Override
    public ServerResponse getByCustId(Integer custId) {
        Customer customer = customerMapper.selectByPrimaryKey(custId);
        if(customer!=null){
            return ServerResponse.getSuccess(customer);

        }
        return ServerResponse.getFail(null);
    }
}
